<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/resources/layui/css/layui.css" media="all">
</head>
<body>
<form class="layui-from" id="addFrm" lay-filter="addFrm" style="padding: 20px">
   <div class="layui-form-item">
    <label class="layui-form-label">公告标题</label>
    <div class="layui-input-block">
      <input type="text" name="title" lay-verify="title"  autocomplete="off" placeholder="请输入公告标题" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">公告内容</label>
    <div class="layui-input-block">
      <textarea class="layui-textarea layui-hide"  name="content" lay-verify="content" id="content"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block" style="text-align: center;">
      <button class="layui-btn" lay-submit="" lay-filter="subAdd" id="subAdd">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>

</body>
<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script type="text/javascript">
	layui.use(["layer","jquery","form","layedit"],function(){
		 var form = layui.form,
	        layer = parent.layer === undefined ? layui.layer : top.layer,
	        $ = layui.jquery,
	        layedit = layui.layedit;
			//创建一个编辑器
		    var editIndex = layedit.build('content');
			
		  //监听提交
		    form.on('submit(subAdd)', function(data){
		     //同步富文本编辑器和文本域的内容
		     layedit.sync(editIndex);
		     var data = $("#addFrm").serialize();
		     $.post("/notice/addNotice?"+data,function(obj){
		    	layer.msg(obj.msg);
		    	//刷新父页面的表格
		    	window.parent.tableIns.reload();
		    	//关闭当前的弹出层
		    	var index=window.parent.layer.getFrameIndex(window.name);
		    	window.parent.layer.close(index);
		     });
		      return false;
		    });
			
			
	});
</script>
</html>